﻿Imports System
Imports System.Runtime.Serialization
Imports System.Security.Permissions

Namespace System.Workflow.Runtime
    <Serializable> _
    Public Class WorkflowOwnershipException
        Inherits Exception
        ' Methods
        Public Sub New()
            MyBase.New(ExecutionStringManager.WorkflowOwnershipException)
        End Sub

        Public Sub New(ByVal instanceId As Guid)
            MyBase.New(ExecutionStringManager.WorkflowOwnershipException)
            Me.InstanceId = instanceId
        End Sub

        Public Sub New(ByVal message As String)
            MyBase.New(message)
        End Sub

        Public Sub New(ByVal instanceId As Guid, ByVal message As String)
            MyBase.New(message)
            Me.InstanceId = instanceId
        End Sub

        <SecurityPermission(SecurityAction.Demand, SerializationFormatter:=True)> _
        Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
            MyBase.New(info, context)
            Me._instanceId = DirectCast(info.GetValue("__instanceId__", GetType(Guid)), Guid)
        End Sub

        Public Sub New(ByVal message As String, ByVal innerException As Exception)
            MyBase.New(message, innerException)
        End Sub

        Public Sub New(ByVal instanceId As Guid, ByVal message As String, ByVal innerException As Exception)
            MyBase.New(message, innerException)
            Me.InstanceId = instanceId
        End Sub

        <SecurityPermission(SecurityAction.Demand, SerializationFormatter:=True)> _
        Public Overrides Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext)
            If (info Is Nothing) Then
                Throw New ArgumentNullException("info")
            End If
            MyBase.GetObjectData(info, context)
            info.AddValue("__instanceId__", Me._instanceId)
        End Sub


        ' Properties
        Public Property InstanceId As Guid
            Get
                Return Me._instanceId
            End Get
            Set(ByVal value As Guid)
                Me._instanceId = value
            End Set
        End Property


        ' Fields
        Private _instanceId As Guid
    End Class
End Namespace

